//
//  RootViewController.m
//  talentview
//
//  Created by lwc on 14-3-14.
//  Copyright (c) 2014年 user. All rights reserved.
//

#import "RootController.h"
#import "ClientSearchViewController.h"
#import "TimerHolder.h"
#import "LaunchViewController.h"
@interface RootController ()<TimerHolderDelegate>
@property (nonatomic,strong)    UIWindow    *window;
@property (nonatomic,strong)    TimerHolder *timerHolder;
@end


@implementation RootController

+ (RootController *)controller: (UIWindow *)window
{
    RootController *instance = [[RootController alloc]init];
    instance.window = window;
    [instance showController];
    return instance;
}
- (void)dealloc
{
    [self.timerHolder stopTimer];
    self.timerHolder.delegate = nil;
}


- (void)showController
{
    self.timerHolder = [[TimerHolder alloc] init];
    [self.timerHolder startTimer:3.0 delegate:self repeats:NO];
    [self showLaunchViewController];
}

- (void)showLaunchViewController
{
    LaunchViewController *vc = [[LaunchViewController alloc]initWithNibName:@"LaunchViewController" bundle:nil];
    self.window.rootViewController = vc;
}

- (void)showMainController
{
    //todo
    ClientSearchViewController *viewController = [[ClientSearchViewController alloc] initWithNibName:@"ClientSearchViewController" bundle:nil];
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:viewController];
    self.window.rootViewController = nav;
}
- (void)onTimerHolderFire: (TimerHolder *)holder
{
    [self showMainController];
}
@end
